﻿//using FirstWinform;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ruoxian_novel
{
    public partial class Main : Form
    {
        string zhanghao1 = "yq";
        public Main(string zhanghao,string sf)
        {
            zhanghao = zhanghao1;
            InitializeComponent();
        }

        private void button10_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button28_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button29_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button12_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button13_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button14_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button15_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button11_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button16_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button77_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button75_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button74_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button73_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button72_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button71_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button70_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button69_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        private void button17_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button18_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        private void button109_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button108_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button107_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button106_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button105_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button104_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button103_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button102_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button101_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        private void button76_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button61_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button60_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button59_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button58_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button57_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button56_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button55_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button54_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button53_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        private void button45_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button44_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button43_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button42_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button41_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button40_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button39_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button38_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button37_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        private void button29_Click_1(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button28_Click_1(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button27_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button26_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button25_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button24_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button23_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button22_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button21_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        private void button93_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button92_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button91_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button90_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button89_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button88_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button87_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button86_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button85_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        private void button141_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button140_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button139_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button138_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button137_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button136_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button135_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button134_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button133_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        private void button125_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button124_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button123_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button122_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button121_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button120_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button119_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button118_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button117_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        //int a1=2302,a2=2211,a3=1044,a4=2445,a5=3501,a6=1445,a7=1225,a8=3552,a9=900,a10=1552,a11=2553,a12=642,a13=366,a14=2556,a15=3466,a16=1526,a17=2312,a18=1551,a19=2566,a20=3556,a21=3255,a22=6437,a23=5744,a24=8533,a25=1555,a26=2561,a27=1526,a28=1255,a29=3262,a30=1256,a31=1246,a32=1256,a33=1256,a34=1256,a35=2412,a36=3511,a37=2356,a38=1455,a39=2145,a40=2562,a41=2551,a42=22,a45=235,a46=1253,a47=214,a48=245,a49=245,a50=245,a51=2521,a52=3326,a53=4125,a54=1245;
        int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12;//, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30;
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
            //将这本书的阅读量显示
            panel11.BringToFront();
            
            label32.Show(); label33.Show(); 
            label35.Hide(); comboBox7.Show(); comboBox8.Show(); label38.Show(); label39.Show();
            label37.Show();

            int id = 5;
            panel11.BringToFront();
            panel11.BringToFront();
            comboBox8.Hide(); label38.Hide(); label39.Hide(); label35.Show(); dgv3.Hide();
            //获取书名
            label35.Text = "《凋落》";
            comboBox8.Text = "《凋落》";
            //点击dgv里书籍，获取章节内容
            string sql1 = string.Format("select zhangjieneirong from zhangjie where bookid='{0}'", id);
            DataTable dt1 = DBHelper.GetDataTable(sql1);
            richTextBox1.Text = dt1.Rows[0][0].ToString();
            //获取选中书的章节，赋给第二个下拉框
            string name3 = comboBox8.Text;
            SqlConnection con33 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da33 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name3), con33);
            DataSet ds33 = new DataSet();
            da33.Fill(ds33, "zhangjie");
            DataTable dtGroup13 = ds33.Tables["zhangjie"];
            comboBox7.DataSource = dtGroup13;
            comboBox7.DisplayMember = "zhangjie";
            comboBox7.ValueMember = "zhangjie";
        }
            catch 
            {

              
            }
        }
        private void button148_Click(object sender, EventArgs e)
        {
            panel10.BringToFront();
        }

        private void Main_Load(object sender, EventArgs e)
        {
            try
            {
            //隐藏dgv和按钮
            dgv.Hide();dgv6.Hide();  bdnInfo.Hide();
            string sql3 = "select * from Books";
            DataTable dt3 = DBHelper.GetDataTable(sql3);
            dgv3.DataSource = dt3;
            //隐藏dgv6
            dgv6.Hide();
            //隐藏
            //为下拉框绑定书名
            SqlConnection con = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da = new SqlDataAdapter("select bookName from books", con);
            DataSet ds = new DataSet();
            da.Fill(ds, "bookname");
            DataTable dtGroup = ds.Tables["bookname"];
            comboBox5.DataSource = dtGroup;
            comboBox5.DisplayMember = "bookname";
            comboBox5.ValueMember = "bookname";
            //为下拉框绑定书名2
            SqlConnection con2 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da2 = new SqlDataAdapter("select bookName from books", con2);
            DataSet ds2 = new DataSet();
            da2.Fill(ds2, "bookname");
            DataTable dtGroup2 = ds2.Tables["bookName"];
            comboBox8.DataSource = dtGroup2;
            comboBox8.DisplayMember = "bookname";
            comboBox8.ValueMember = "bookname";
            //为下拉框绑定书名
            SqlConnection con4 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da4 = new SqlDataAdapter("select bookName from books", con4);
            DataSet ds4 = new DataSet();
            da4.Fill(ds4, "bookname");
            DataTable dtGroup4 = ds4.Tables["bookname"];
            comboBox9.DataSource = dtGroup4;
            comboBox9.DisplayMember = "bookname";
            comboBox9.ValueMember = "bookname";

            //为下拉框绑定书编号，书本数量
            SqlConnection con5 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da5 = new SqlDataAdapter("select bookid from books", con5);
            DataSet ds5 = new DataSet();
            da5.Fill(ds5, "bookid");
            DataTable dtGroup5 = ds5.Tables["bookid"];
            comboBox11.DataSource = dtGroup5;
            comboBox11.DisplayMember = "bookid";
            comboBox11.ValueMember = "bookid";
            //为下拉框绑定分类
            SqlConnection con6 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da6 = new SqlDataAdapter("select fenlei from fenlei", con6);
            DataSet ds6 = new DataSet();
            da6.Fill(ds6, "fenlei");
            DataTable dtGroup6 = ds6.Tables["fenlei"];
            comboBox3.DataSource = dtGroup6;
            comboBox3.DisplayMember = "fenlei";
            comboBox3.ValueMember = "fenlei";
            //为下拉框绑定书籍状态
            SqlConnection con61 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da61 = new SqlDataAdapter("select bookzhuangtai from bookzhuangtai", con6);
            DataSet ds61 = new DataSet();
            da61.Fill(ds61, "bookzhuangtai");
            DataTable dtGroup61 = ds61.Tables["bookzhuangtai"];
            comboBox4.DataSource = dtGroup61;
            comboBox4.DisplayMember = "bookzhuangtai";
            comboBox4.ValueMember = "bookzhuangtai";         
                
            }
            catch 
            {

              
            }

        }

        private void button1_Click(object sender, EventArgs e)
        {
            panel12.BringToFront();panel13.Hide();
            dgv.Hide();dgv6.Hide();button161.Hide();   bdnInfo.Hide();
        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            try
            {
            panel13.Show();
            panel13.BringToFront();
            dgv6.Hide(); bdnInfo.Show();
            dgv.Show();
                bdnInfo.Show();

                //数据库连接字符串，分页
                string strConn = "server=.;database=booksDB;Integrated Security=true;";
            SqlConnection conn = new SqlConnection(strConn);
            conn.Open();
            string strSql = string.Format("select a.bookID ,b.Fenlei,a.bookName ,a.bookGengxin ,c.bookZhuangtai ,a.bookJianjie from Books a join fenlei b on a.bookFenlei=b.FenleiID join BookZhuangtai c on a.bookZhuangtai=c.bookZhuangtaiID where a.bookZuozhe='{0}' and a.Fengjin='{1}'", Yonghu.zhanghao,"正常");
            dgv.DataSource = DBHelper.GetDataTable(strSql);
            SqlDataAdapter sda = new SqlDataAdapter(strSql, conn);
            DataSet ds1 = new DataSet();
            sda.Fill(ds1, "ds");
            conn.Close();
            dtInfo = ds1.Tables[0];
            InitDataSet();
            }
            catch
            {
            }
        }

        private void button3_Click_1(object sender, EventArgs e)
        {
            try
            {
            panel14.BringToFront();
            comboBox3.Text = "-请选择类别-";
            comboBox4.Text = "-请选择状态-";
            //循环下拉框
            string ptr = comboBox11.SelectedText; //查询系统表中 打印机名称
            int i = 0;
            for (i = 0; i < comboBox11.Items.Count; i++)
            {
                if (comboBox11.Items[i].ToString() == ptr)
                {
                    comboBox11.SelectedIndex = i;
                    break;
                }
            }
            label28.Text = (i).ToString();
            }
            catch
            {
            }
        }

        private void button153_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button154_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button155_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button156_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button157_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button158_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button150_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button151_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button152_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
            if (comboBox1.Text == "状态")
            {
                textBox1.Hide();
                comboBox2.Hide(); comboBox2.Text = ""; comboBox10.Hide();comboBox12.Show();
                    //comboBox2.Items.Clear();
                    //comboBox2.Items.Add("全部"); comboBox2.Items.Add("连载"); comboBox2.Items.Add("完结");  comboBox2.Items.Add("暂停");
                    //绑定状态
                    SqlConnection con6 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                    SqlDataAdapter da6 = new SqlDataAdapter("select bookzhuangtai from bookzhuangtai", con6);
                    DataSet ds6 = new DataSet();
                    da6.Fill(ds6, "bookzhuangtai");
                    DataTable dtGroup6 = ds6.Tables["bookzhuangtai"];
                    comboBox12.DataSource = dtGroup6;
                    comboBox12.DisplayMember = "bookzhuangtai";
                    comboBox12.ValueMember = "bookzhuangtai";
                }
            else if (comboBox1.Text == "按书籍类型")
            {
                textBox1.Hide();
                    comboBox2.Hide();
                    comboBox10.Show(); comboBox12.Hide();
                    //comboBox2.Items.Add("玄幻"); comboBox2.Items.Add("魔幻"); comboBox2.Items.Add("武侠");
                    //comboBox2.Items.Add("修仙"); comboBox2.Items.Add("历史"); comboBox2.Items.Add("军事");
                    //comboBox2.Items.Add("都市"); comboBox2.Items.Add("科幻"); comboBox2.Items.Add("游戏");
                    //comboBox2.Items.Add("悬疑"); comboBox2.Items.Add("灵异"); comboBox2.Items.Add("竞技");
                    //comboBox2.Items.Add("同人"); comboBox2.Items.Add("言情"); comboBox2.Items.Add("纯爱");
                    //绑定书籍类型
                    SqlConnection con66 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                    SqlDataAdapter da66 = new SqlDataAdapter("select fenlei from fenlei", con66);
                    DataSet ds66 = new DataSet();
                    da66.Fill(ds66, "fenlei");
                    DataTable dtGroup66 = ds66.Tables["fenlei"];
                    comboBox10.DataSource = dtGroup66;
                    comboBox10.DisplayMember = "fenlei";
                    comboBox10.ValueMember = "fenlei";
                       
                }
            else if (comboBox1.Text == "按书籍上架时间分类")
            {

                comboBox2.Items.Clear();
                textBox1.Hide();
                    comboBox10.Hide();
                    comboBox2.Show();
                    comboBox2.Text = "";
                    comboBox10.Text = "";
                    comboBox12.Text = "";
                    textBox1.Text = "";
                    comboBox12.Hide();
                }
            else if (comboBox1.Text == "按作者分类")
            {
                textBox1.Hide(); comboBox10.Hide(); comboBox12.Hide();
                    comboBox2.Show(); comboBox2.Text = "";
                    comboBox2.Items.Clear();
                //绑定作者
                SqlConnection con67 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                SqlDataAdapter da67 = new SqlDataAdapter("select zhanghao from yonghu", con67);
                DataSet ds67 = new DataSet();
                da67.Fill(ds67, "zhanghao");
                DataTable dtGroup67 = ds67.Tables["zhanghao"];
                comboBox2.DataSource = dtGroup67;
                comboBox2.DisplayMember = "zhanghao";
                comboBox2.ValueMember = "zhanghao";
                    con67.Close();
                    if (comboBox1.Text != "按作者分类")
                    {
                        con67.Close();
                        comboBox2.Items.Clear();
                    }
                }
            else
            {
                comboBox2.Hide(); comboBox10.Hide();
                    textBox1.Show(); comboBox12.Hide();
                }
            }
            catch
            {
            }
        }

        private void 刷新ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
            string sql = string.Format("select a.bookID as 编号, b.Fenlei as 分类, a.bookName as 书名, a.bookGengxin as 更新时间, c.bookZhuangtai as 状态, a.bookJianjie as 简介 from Books a join fenlei b on a.bookFenlei=b.FenleiID join BookZhuangtai c on a.bookZhuangtai=c.bookZhuangtaiID where a.bookZuozhe='{0}' and a.Fengjin='{1}'", Yonghu.zhanghao, "正常");
            DataTable dt = DBHelper.GetDataTable(sql);
            dgv.DataSource = dt;
            }
            catch
            {


            }
        }

        private void button160_Click(object sender, EventArgs e)
        {
            panel15.BringToFront(); button161.Show();
        }

        private void button159_Click(object sender, EventArgs e)
        {
            try
            {
            string name = textBox1.Text;
            if (comboBox1.Text == "按书籍名称")
            {
                if (string.IsNullOrEmpty(textBox1.Text))
                {
                    if (dgv.DataSource == "")
                    {
                        MessageBox.Show("查无此书");
                    }
                }
                else
                {
                    string sql1 = string.Format("select a.bookID as 编号,b.Fenlei as 分类,a.bookName as 书名,a.bookGengxin as 更新时间,c.bookZhuangtai as 状态,a.bookJianjie as 简介 from Books a join fenlei b on a.bookFenlei=b.FenleiID join BookZhuangtai c on a.bookZhuangtai=c.bookZhuangtaiID where a.bookZuozhe='{0}' and a.Fengjin='{1}' and a.bookName like '%{2}%'", Yonghu.zhanghao,"正常",name);
                    DataTable dt1 = DBHelper.GetDataTable(sql1);
                    dgv.DataSource = dt1;
                    }
            }
            if (comboBox1.Text == "状态")
            {
                try
                {
                string zt = comboBox12.Text; 
                        int zt2 = 0;
                if (zt == "全部")
                {
                    zt2 = 0;
                }
                else if (zt == "连载")
                {
                    zt2 = 1;
                }
                else if (zt == "完结")
                {
                    zt2 = 2;
                }
                else if (zt == "暂停")
                {
                    zt2 = 3;
                }
                string sql = string.Format("select a.bookID as 编号, b.Fenlei as 分类, a.bookName as 书名, a.bookGengxin as 更新时间, c.bookZhuangtai as 状态, a.bookJianjie as 简介 from Books a join fenlei b on a.bookFenlei = b.FenleiID join BookZhuangtai c on a.bookZhuangtai = c.bookZhuangtaiID where a.bookZuozhe = '{0}' and a.Fengjin = '{1}' and a.bookZhuangtai = '{2}'", Yonghu.zhanghao,"正常",zt2);
                DataTable dt = DBHelper.GetDataTable(sql);
                dgv.DataSource = dt;
                    }
                catch
                {

                    MessageBox.Show("请联系管理员");
                }

            }   
            if (comboBox1.Text == "按书籍类型")
            {
                //按书籍类型查询
                string lx = comboBox10.Text;
                string sql = string.Format("select a.bookID as 编号,b.Fenlei as 分类,a.bookName as 书名,a.bookGengxin as 更新时间,c.bookZhuangtai as 状态,a.bookJianjie as 简介    from Books a join fenlei b on a.bookFenlei=b.FenleiID join BookZhuangtai c on a.bookZhuangtai=c.bookZhuangtaiID where a.bookZuozhe='{0}' and a.Fengjin='{1}' and b.Fenlei='{2}'", Yonghu.zhanghao,"正常",lx);
                DataTable dt = DBHelper.GetDataTable(sql);
                dgv.DataSource = dt; 
            }
            if (comboBox1.Text == "按书籍上架时间")
            {
                //按书籍上架时间查询
                string sql = string.Format("select a.bookID as 编号,b.Fenlei as 分类,a.bookName as 书名,a.bookGengxin as 更新时间,c.bookZhuangtai as 状态,a.bookJianjie as 简介 from Books a join fenlei b on a.bookFenlei=b.FenleiID join BookZhuangtai c on a.bookZhuangtai=c.bookZhuangtaiID where a.bookZuozhe='{0}' and a.Fengjin='{1}' order by a.bookTime desc",Yonghu.zhanghao,"正常");
                DataTable dt = DBHelper.GetDataTable(sql);
                dgv.DataSource = dt;
                }
           
             dgv.AutoGenerateColumns = false;
        }
            catch 
            {

              
            }

        }

        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
           
        }

        private void button162_Click(object sender, EventArgs e)
        { string k = "";
            try
            {
               
                int fl = 0; string nr = textBox3.Text;
            //
            if (comboBox3.Text == "玄幻")
            {
                fl = 1;
            }
            if (comboBox3.Text == "魔幻")
            {
                fl = 2;
            }
            if (comboBox3.Text == "武侠")
            {
                fl = 3;
            }
            if (comboBox3.Text == "修仙")
            {
                fl = 4;
            }
            if (comboBox3.Text == "历史")
            {
                fl = 5;
            }
            if (comboBox3.Text == "军事")
            {
                fl = 6;
            }
            if (comboBox3.Text == "都市")
            {
                fl = 7;
            }
            if (comboBox3.Text == "青春")
            {
                fl = 8;
            }
            //
            int zt = 0;
            if (comboBox4.Text == "全部")
            {
                zt = 0;
            }
            if (comboBox4.Text == "连载")
            {
                zt = 1;
            }
            if (comboBox4.Text == "完结")
            {
                zt = 2;
            }
            if (comboBox4.Text == "暂停")
            {
                zt = 3;
            }
            //新添加书籍不能同名，否则报错
            string name = comboBox9.Text;
            string zz = "1000000002";
            string jj = textBox8.Text;
            string ptr = comboBox11.SelectedText; //查询系统表中 打印机名称
            int i;
            for (i = 0; i < comboBox11.Items.Count; i++)
            {
                if (comboBox11.Items[i].ToString() == ptr)
                {
                    comboBox11.SelectedIndex = i;
                    break;
                }
            }
            label28.Text = (i).ToString();
            int id = int.Parse(label28.Text);
            id = id + 1;
            string fj = "正常";
            
                if (string.IsNullOrEmpty(textBox7.Text) && string.IsNullOrEmpty(textBox3.Text))
                {
                    string sql = string.Format("insert into Books values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", id, fl, name, zz, k, zt, k, jj, fj);
                    if (DBHelper.ExecuteNonQuery(sql))
                    {
                        MessageBox.Show("新添书籍成功");
                        //为下拉框绑定书编号，书本数量
                        SqlConnection con5 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                        SqlDataAdapter da5 = new SqlDataAdapter("select bookid from books", con5);
                        DataSet ds5 = new DataSet();
                        da5.Fill(ds5, "bookid");
                        DataTable dtGroup5 = ds5.Tables["bookid"];
                        comboBox11.DataSource = dtGroup5;
                        comboBox11.DisplayMember = "bookid";
                        comboBox11.ValueMember = "bookid";
                        //为下拉框绑定书名2
                        SqlConnection con2 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                        SqlDataAdapter da2 = new SqlDataAdapter("select bookName from books", con2);
                        DataSet ds2 = new DataSet();
                        da2.Fill(ds2, "bookname");
                        DataTable dtGroup2 = ds2.Tables["bookName"];
                        comboBox8.DataSource = dtGroup2;
                        comboBox8.DisplayMember = "bookname";
                        comboBox8.ValueMember = "bookname";
                        //为下拉框绑定书名2
                        SqlConnection con3 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                        SqlDataAdapter da3 = new SqlDataAdapter("select bookName from books", con3);
                        DataSet ds3 = new DataSet();
                        da3.Fill(ds3, "bookname");
                        DataTable dtGroup3 = ds3.Tables["bookName"];
                        comboBox5.DataSource = dtGroup3;
                        comboBox5.DisplayMember = "bookname";
                        comboBox5.ValueMember = "bookname";
                    }
                    else
                    {
                        MessageBox.Show("请联系管理员1");
                        //为下拉框绑定书编号，书本数量
                        SqlConnection con5 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                        SqlDataAdapter da5 = new SqlDataAdapter("select bookid from books", con5);
                        DataSet ds5 = new DataSet();
                        da5.Fill(ds5, "bookid");
                        DataTable dtGroup5 = ds5.Tables["bookid"];
                        comboBox11.DataSource = dtGroup5;
                        comboBox11.DisplayMember = "bookid";
                        comboBox11.ValueMember = "bookid";
                        //为下拉框绑定书名2
                        SqlConnection con2 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                        SqlDataAdapter da2 = new SqlDataAdapter("select bookName from books", con2);
                        DataSet ds2 = new DataSet();
                        da2.Fill(ds2, "bookname");
                        DataTable dtGroup2 = ds2.Tables["bookName"];
                        comboBox8.DataSource = dtGroup2;
                        comboBox8.DisplayMember = "bookname";
                        comboBox8.ValueMember = "bookname";
                        //为下拉框绑定书名2
                        SqlConnection con3 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                        SqlDataAdapter da3 = new SqlDataAdapter("select bookName from books", con3);
                        DataSet ds3 = new DataSet();
                        da3.Fill(ds3, "bookname");
                        DataTable dtGroup3 = ds3.Tables["bookName"];
                        comboBox5.DataSource = dtGroup3;
                        comboBox5.DisplayMember = "bookname";
                        comboBox5.ValueMember = "bookname";
                    }
                }
                else
                {
                    string zjmc = textBox7.Text;
                    string diyizhang = "第一章";
                    string sql = string.Format("insert into Books values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", id, fl, name, zz, k, zt, k, jj, fj);
                    string sql1 = string.Format("insert into Zhangjie values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", id, diyizhang, zjmc, nr, id, k, fj);
                    if (DBHelper.ExecuteNonQuery(sql) && DBHelper.ExecuteNonQuery(sql1))
                    {
                        MessageBox.Show("新添书籍及内容成功");
                        //为下拉框绑定书编号，书本数量
                        SqlConnection con5 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                        SqlDataAdapter da5 = new SqlDataAdapter("select bookid from books", con5);
                        DataSet ds5 = new DataSet();
                        da5.Fill(ds5, "bookid");
                        DataTable dtGroup5 = ds5.Tables["bookid"];
                        comboBox11.DataSource = dtGroup5;
                        comboBox11.DisplayMember = "bookid";
                        comboBox11.ValueMember = "bookid";
                        //为下拉框绑定书名2
                        SqlConnection con2 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                        SqlDataAdapter da2 = new SqlDataAdapter("select bookName from books", con2);
                        DataSet ds2 = new DataSet();
                        da2.Fill(ds2, "bookname");
                        DataTable dtGroup2 = ds2.Tables["bookName"];
                        comboBox8.DataSource = dtGroup2;
                        comboBox8.DisplayMember = "bookname";
                        comboBox8.ValueMember = "bookname";
                        //为下拉框绑定书名2
                        SqlConnection con3 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                        SqlDataAdapter da3 = new SqlDataAdapter("select bookName from books", con3);
                        DataSet ds3 = new DataSet();
                        da3.Fill(ds3, "bookname");
                        DataTable dtGroup3 = ds3.Tables["bookName"];
                        comboBox5.DataSource = dtGroup3;
                        comboBox5.DisplayMember = "bookname";
                        comboBox5.ValueMember = "bookname";
                    }
                    else
                    {
                        MessageBox.Show("请联系管理员2");
                        //为下拉框绑定书编号，书本数量
                        SqlConnection con5 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                        SqlDataAdapter da5 = new SqlDataAdapter("select bookid from books", con5);
                        DataSet ds5 = new DataSet();
                        da5.Fill(ds5, "bookid");
                        DataTable dtGroup5 = ds5.Tables["bookid"];
                        comboBox11.DataSource = dtGroup5;
                        comboBox11.DisplayMember = "bookid";
                        comboBox11.ValueMember = "bookid";
                        //为下拉框绑定书名2
                        SqlConnection con2 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                        SqlDataAdapter da2 = new SqlDataAdapter("select bookName from books", con2);
                        DataSet ds2 = new DataSet();
                        da2.Fill(ds2, "bookname");
                        DataTable dtGroup2 = ds2.Tables["bookName"];
                        comboBox8.DataSource = dtGroup2;
                        comboBox8.DisplayMember = "bookname";
                        comboBox8.ValueMember = "bookname";  
                        //为下拉框绑定书名2
                        SqlConnection con3 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                        SqlDataAdapter da3 = new SqlDataAdapter("select bookName from books", con3);
                        DataSet ds3 = new DataSet();
                        da3.Fill(ds3, "bookname");
                        DataTable dtGroup3 = ds3.Tables["bookName"];
                        comboBox5.DataSource = dtGroup3;
                        comboBox5.DisplayMember = "bookname";
                        comboBox5.ValueMember = "bookname";
                    }
                }

            }
            catch
            {
                MessageBox.Show("新添书籍及内容成功");
                //为下拉框绑定书编号，书本数量
                SqlConnection con5 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                SqlDataAdapter da5 = new SqlDataAdapter("select bookid from books", con5);
                DataSet ds5 = new DataSet();
                da5.Fill(ds5, "bookid");
                DataTable dtGroup5 = ds5.Tables["bookid"];
                comboBox11.DataSource = dtGroup5;
                comboBox11.DisplayMember = "bookid";
                comboBox11.ValueMember = "bookid";
                //为下拉框绑定书名2
                SqlConnection con2 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                SqlDataAdapter da2 = new SqlDataAdapter("select bookName from books", con2);
                DataSet ds2 = new DataSet();
                da2.Fill(ds2, "bookname");
                DataTable dtGroup2 = ds2.Tables["bookName"];
                comboBox8.DataSource = dtGroup2;
                comboBox8.DisplayMember = "bookname";
                comboBox8.ValueMember = "bookname";
                //为下拉框绑定书名2
                SqlConnection con3 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                SqlDataAdapter da3 = new SqlDataAdapter("select bookName from books", con3);
                DataSet ds3 = new DataSet();
                da3.Fill(ds3, "bookname");
                DataTable dtGroup3 = ds3.Tables["bookName"];
                comboBox5.DataSource = dtGroup3;
                comboBox5.DisplayMember = "bookname";
                comboBox5.ValueMember = "bookname";
            }
            
            comboBox3.Text = k; comboBox4.Text = k; textBox8.Text = k;
            textBox7.Text = k; textBox3.Text = k;

        }

        private void dgv_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
            //查看章节，并给dgv6绑定章节章数
            string name = dgv.SelectedRows[0].Cells["c_bookName"].Value.ToString();
            dgv6.Show();
            dgv6.BringToFront();
            string sql3 = string.Format("select a.bookname, b.zhangjie, b.zhangjiename from books a join zhangjie b on a.bookid = b.bookid where a.bookname = '{0}'",name);
            DataTable dt3 = DBHelper.GetDataTable(sql3);
            dgv6.DataSource = dt3;
            }
            catch 
            {
            }
        }
        private void label33_Click(object sender, EventArgs e)
        {
            try
            {


                //获取ID方便查询对应的书籍
                int id = int.Parse(dgv3.SelectedRows[0].Cells[0].Value.ToString());
                panel11.BringToFront();
                //通过书籍获取章数  string zhangshu = string.Format("select count(*) from zhangjie where bookid={0}", id);
                int i = 0;
                for (; i <= 1; i++)
                {
                    int a = int.Parse(label90.Text) - i;
                    label90.Text = (a).ToString();
                }
                int hang = int.Parse(label90.Text);
                string sql2 = string.Format("select zhangjie from zhangjie where bookid='{0}' and zhangjieid='{1}'", id, label90.Text);
                DataTable dt2 = DBHelper.GetDataTable(sql2);
                comboBox7.Text = dt2.Rows[0][0].ToString();

                do
                {
                    string sql1 = string.Format("select * from zhangjie where bookid='{0}'", id);
                    DataTable dt1 = DBHelper.GetDataTable(sql1);
                    dgv4.DataSource = dt1;
                    richTextBox1.Text = dt1.Rows[hang][3].ToString();
                    i++;
                } while (label90.Text == "20");

            }
            catch
            {
               

            }
        }
        
        private void label32_Click(object sender, EventArgs e)
        {
            try
            {

           
            //获取ID方便查询对应的书籍
            int id = int.Parse(dgv3.SelectedRows[0].Cells[0].Value.ToString());
            panel11.BringToFront();
            //通过书籍获取章数  string zhangshu = string.Format("select count(*) from zhangjie where bookid={0}", id);
            int i = 0;
            for (; i <= 1; i++)
            {
                int a = int.Parse(label90.Text) + i;
                label90.Text = (a).ToString();
            }
            int hang = int.Parse(label90.Text);
            string sql2 = string.Format("select zhangjie from zhangjie where bookid='{0}' and zhangjieid='{1}'",id,label90.Text);
            DataTable dt2 = DBHelper.GetDataTable(sql2);
            comboBox7.Text= dt2.Rows[0][0].ToString();
   
                do
                {
                    string sql1 = string.Format("select * from zhangjie where bookid='{0}'",id);
                    DataTable dt1 = DBHelper.GetDataTable(sql1);
                    dgv4.DataSource = dt1;
                    richTextBox1.Text = dt1.Rows[hang][3].ToString();
                    i++;
                } while (label90.Text== "20");

            }
            catch
            {
               

            }
        }

        private void comboBox5_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
            //获取选中书的章节
            string name = comboBox5.Text;
            string sql2 = string.Format("select * from Books where bookname='{0}'",name);
            DataTable dt2 = DBHelper.GetDataTable(sql2);
            dgv1.DataSource = dt2;

            SqlConnection con1 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da1 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name), con1);
            DataSet ds1 = new DataSet();
            da1.Fill(ds1, "zhangjie");
            DataTable dtGroup1 = ds1.Tables["zhangjie"];
            comboBox6.DataSource = dtGroup1;
            comboBox6.DisplayMember = "zhangjie";
            comboBox6.ValueMember = "zhangjie";

            string name1 = comboBox5.Text;
            string id = string.Format("select bookid from books where bookname='{0}'", name1);
               }
            catch 
            {

               
            }
        }

        private void button161_Click(object sender, EventArgs e)
        {
            try
            {
                string sql5 = "select count(zhangjieid) from zhangjie ";
                DataTable dt5 = DBHelper.GetDataTable(sql5);
                label40.Text = dt5.Rows[0][0].ToString();
                int id = int.Parse(label40.Text) + 1;

            int b = int.Parse(dgv1.SelectedRows[0].Cells["id"].Value.ToString());
            string zjname = textBox5.Text;
            string z = comboBox6.Text;
            string nr = textBox4.Text;
            string fj = "正常";
            int bb = 0;
            switch (z)
            {
                case "第一章":
                    bb = 1;
                    break;
                case "第二章":
                    bb = 2;
                    break;
                case "第三章":
                    bb = 3;
                    break;
                case "第四章":
                    bb = 4;
                    break;
                case "第五章":
                    bb = 5;
                    break;
                case "第六章":
                    bb = 6;
                    break;
                case "第七章":
                    bb = 7;
                    break;
                case "第八章":
                    bb = 8;
                    break;
                case "第九章":
                    bb = 9;
                    break;
                case "第十章":
                    bb = 10;
                    break;
                case "第十一章":
                    bb = 11;
                    break;
                default:
                    break;
            }
            if (string.IsNullOrEmpty(textBox5.Text)||string.IsNullOrEmpty(textBox4.Text))
            {
                MessageBox.Show("请将数据填写完整");
            }
            else
            {
                try
                {
                    string sql = string.Format("insert into zhangjie values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", id, z, zjname, nr, b, "", fj);
                    if (DBHelper.ExecuteNonQuery(sql))
                    {
                        MessageBox.Show("添加成功");
                        //获取选中书的章节
                        string name = comboBox5.Text;
                        SqlConnection con1 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                        SqlDataAdapter da1 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'",     name), con1);
                        DataSet ds1 = new DataSet();
                        da1.Fill(ds1, "zhangjie");
                        DataTable dtGroup1 = ds1.Tables["zhangjie"];
                        comboBox6.DataSource = dtGroup1;
                        comboBox6.DisplayMember = "zhangjie";
                        comboBox6.ValueMember = "zhangjie";
                        //获取选中书的章节。重新绑定数据
                        string name2 = comboBox8.Text;
                        SqlConnection con3 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                        SqlDataAdapter da3 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'",     name2), con3);
                        DataSet ds3 = new DataSet();
                        da3.Fill(ds3, "zhangjie");
                        DataTable dtGroup2 = ds3.Tables["zhangjie"];
                        comboBox7.DataSource = dtGroup2;
                        comboBox7.DisplayMember = "zhangjie";
                        comboBox7.ValueMember = "zhangjie";
                        textBox4.Text = "";
                        //为下拉框绑定书名2
                        SqlConnection con4 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                        SqlDataAdapter da4 = new SqlDataAdapter("select bookName from books", con4);
                        DataSet ds4 = new DataSet();
                        da4.Fill(ds4, "bookname");
                        DataTable dtGroup4 = ds4.Tables["bookName"];
                        comboBox8.DataSource = dtGroup4;
                        comboBox8.DisplayMember = "bookname";
                        comboBox8.ValueMember = "bookname";
                        //分类
                        SqlConnection con5 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                        SqlDataAdapter da5 = new SqlDataAdapter("select fenlei from fenlei", con5);
                        DataSet ds5 = new DataSet();
                        da5.Fill(ds5, "fenglei");
                        DataTable dtGroup5 = ds5.Tables["fenglei"];
                        comboBox6.DataSource = dtGroup1;
                        comboBox6.DisplayMember = "fenglei";
                        comboBox6.ValueMember = "fenglei";

                }
                else
                        {
                        MessageBox.Show("添加失败");
                        }
                }
                catch
                {

                }
                }
            }
            catch
            {


            }


        }

        private void 删除书籍ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {

            
            int id =int.Parse(dgv.SelectedRows[0].Cells[0].Value.ToString());
            string sql = string.Format("delete from books where bookid='{0}'",id);
            //温馨提示
            if (MessageBox.Show("确定删除?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (DBHelper.ExecuteNonQuery(sql))
                {
                    MessageBox.Show("删除成功");
                    //刷新
                    string sql1 = string.Format("select a.bookID as 编号,b.Fenlei as 分类,a.bookName as 书名,a.bookGengxin as 更新时间,c.bookZhuangtai as 状态,a.bookJianjie as 简介 from Books a join fenlei b on a.bookFenlei=b.FenleiID join BookZhuangtai c on a.bookZhuangtai=c.bookZhuangtaiID where a.bookZuozhe='{0}' and a.Fengjin='{1}'",Yonghu.zhanghao,"正常");
                    DataTable dt = DBHelper.GetDataTable(sql1);
                    dgv.DataSource = dt;
                    //为下拉框绑定书编号，书本数量
                    SqlConnection con5 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                    SqlDataAdapter da5 = new SqlDataAdapter("select bookid from books", con5);
                    DataSet ds5 = new DataSet();
                    da5.Fill(ds5, "bookid");
                    DataTable dtGroup5 = ds5.Tables["bookid"];
                    comboBox11.DataSource = dtGroup5;
                    comboBox11.DisplayMember = "bookid";
                    comboBox11.ValueMember = "bookid";
                    //获取选中书的章节
                    string name = comboBox5.Text;
                    SqlConnection con1 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                    SqlDataAdapter da1 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name), con1);
                    DataSet ds1 = new DataSet();
                    da1.Fill(ds1, "zhangjie");
                    DataTable dtGroup1 = ds1.Tables["zhangjie"];
                    comboBox6.DataSource = dtGroup1;
                    comboBox6.DisplayMember = "zhangjie";
                    comboBox6.ValueMember = "zhangjie";
                    //获取选中书的章节。重新绑定数据
                    string name2 = comboBox8.Text;
                    SqlConnection con3 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                    SqlDataAdapter da3 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name2), con3);
                    DataSet ds3 = new DataSet();
                    da3.Fill(ds3, "zhangjie");
                    DataTable dtGroup2 = ds3.Tables["zhangjie"];
                    comboBox7.DataSource = dtGroup2;
                    comboBox7.DisplayMember = "zhangjie";
                    comboBox7.ValueMember = "zhangjie";
                    textBox4.Text = "";
                    //为下拉框绑定书名2
                    SqlConnection con4 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                    SqlDataAdapter da4 = new SqlDataAdapter("select bookName from books", con4);
                    DataSet ds4 = new DataSet();
                    da4.Fill(ds4, "bookname");
                    DataTable dtGroup4 = ds4.Tables["bookName"];
                    comboBox8.DataSource = dtGroup4;
                    comboBox8.DisplayMember = "bookname";
                    comboBox8.ValueMember = "bookname";
                }
            }
            else
                {
                    MessageBox.Show("犹豫就会败北，冲动就会白给");
                }
            }
            catch
            {


            }
        }

        private void 删除章节JToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
            //查看章节，并给dgv6绑定章节章数
            string name = dgv.SelectedRows[0].Cells[2].Value.ToString();
            dgv6.Show();
            dgv6.BringToFront();
            string sql3 = string.Format("select a.bookname, b.zhangjie, b.zhangjiename from books a join zhangjie b on a.bookid = b.bookid where a.bookname = '{0}'", name);
            DataTable dt3 = DBHelper.GetDataTable(sql3);
            dgv6.DataSource = dt3;
            }
            catch
            {


            }
        }

        private void comboBox7_SelectedIndexChanged(object sender, EventArgs e)
        {

        }   
        // 1、定义几个所需的公有成员：
        int pageSize = 0;     //每页显示行数
        int nMax = 0;         //总记录数
        int pageCount = 0;    //页数＝总记录数/每页显示行数
        int pageCurrent = 0;   //当前页号
        int nCurrent = 0;      //当前记录行
        DataSet ds = new DataSet();
        DataTable dtInfo = new DataTable();
        private void InitDataSet()
        {
            try
            {
            pageSize = 10;      //设置页面行数
            nMax = dtInfo.Rows.Count;
            pageCount = (nMax / pageSize);    //计算出总页数
            if ((nMax % pageSize) > 0) pageCount++;
            pageCurrent = 1;    //当前页数从1开始
            nCurrent = 0;       //当前记录数从0开始
            LoadData();
            }
            catch
            {


            }
        }

        private void comboBox7_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            try
            {
            //通过comboBox7第几章查找内容，显示在文本框里
            string zj = comboBox7.Text;
            string bookname = comboBox8.Text;
            string sql = string.Format("select zhangjieneirong from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}' and b.zhangjie='{1}'", bookname, zj);
            DataTable dt = DBHelper.GetDataTable(sql);
            richTextBox1.Text = dt.Rows[0][0].ToString();
            }
            catch
            {


            }
        }

        private void label38_Click(object sender, EventArgs e)
        {

        }

        private void comboBox8_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {

            //获取选中书的章节，赋给第二个下拉框
            string name = comboBox8.Text;
            SqlConnection con3 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da3 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name), con3);
            DataSet ds3 = new DataSet();
            da3.Fill(ds3, "zhangjie");
            DataTable dtGroup1 = ds3.Tables["zhangjie"];
            comboBox7.DataSource = dtGroup1;
            comboBox7.DisplayMember = "zhangjie";
            comboBox7.ValueMember = "zhangjie";

            //为dgv3刷新选中书籍，从而获取id
            string bookname = comboBox8.Text;
            string sql = string.Format("select * from books where bookname='{0}'", bookname);
            DataTable dt2 = DBHelper.GetDataTable(sql);
            dgv3.DataSource = dt2;

                string id2 = dgv3.SelectedRows[0].Cells["dataGridViewTextBoxColumn1"].Value.ToString();//书籍ID
                string sql22 = string.Format("select * from zhangjie where bookid='{0}'", id2);
                DataTable dt22 = DBHelper.GetDataTable(sql22);
                dgv4.DataSource = dt22;

                string id = dgv3.SelectedRows[0].Cells[0].Value.ToString();
                //绑定章节id
                string sql12 = string.Format("select * from zhangjie where bookid='{0}'", id);
                DataTable dt12 = DBHelper.GetDataTable(sql12);
                label90.Text = dt12.Rows[0][0].ToString();
                string zj = comboBox7.Text;
            }
            catch
            {


            }
        }

        private void button164_Click(object sender, EventArgs e)
        {
            panel11.BringToFront();
            label32.Show(); label33.Show(); 
            label35.Hide();comboBox7.Show();comboBox8.Show();label38.Show();label39.Show();
            label37.Show();
            comboBox7.BringToFront();
            //绑定章节id
            string sql12 = "select * from zhangjie";
            DataTable dt12 = DBHelper.GetDataTable(sql12);
            label90.Text = dt12.Rows[0][0].ToString();
        }

        private void panel11_Paint(object sender, PaintEventArgs e)
        {
            try
            {
            //获取书籍名称、章节显示内容
            string zj = comboBox7.Text;

            //获取章节、书籍ID，删除章节
            //刷新dgv4里内容
            string id = dgv3.SelectedRows[0].Cells["dataGridViewTextBoxColumn1"].Value.ToString();//书籍ID
            string sql2 = string.Format("select * from zhangjie where bookid='{0}'", id);
                DataTable dt2 = DBHelper.GetDataTable(sql2);
            dgv4.DataSource = dt2;

                //要判断dgv4里是否有内容，否则会报错
            }
            catch
            {


            }

        }

        private void comboBox11_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
            //为下拉框绑定书名
            SqlConnection con4 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            string id = comboBox11.Text;
            SqlDataAdapter da4 = new SqlDataAdapter(string.Format("select bookName from books where bookid='{0}'",id), con4);
            DataSet ds4 = new DataSet();
            da4.Fill(ds4, "bookname");
            DataTable dtGroup4 = ds4.Tables["bookname"];
            comboBox9.DataSource = dtGroup4;
            comboBox9.DisplayMember = "bookname";
            comboBox9.ValueMember = "bookname";
            }
            catch
            {


            }
        }

        private void button165_Click_1(object sender, EventArgs e)
        {
            try
            {
            string k = "";
            int fl = 0; string nr = textBox3.Text;
            if (comboBox3.Text == "玄幻")
            {
                fl = 1;
            }
            if (comboBox3.Text == "魔幻")
            {
                fl = 2;
            }
            if (comboBox3.Text == "武侠")
            {
                fl = 3;
            }
            if (comboBox3.Text == "修仙")
            {
                fl = 4;
            }
            if (comboBox3.Text == "历史")
            {
                fl = 5;
            }
            if (comboBox3.Text == "军事")
            {
                fl = 6;
            }
            if (comboBox3.Text == "都市")
            {
                fl = 7;
            }
            if (comboBox3.Text == "青春")
            {
                fl = 8;
            }
            int zt = 0;
            if (comboBox4.Text == "全部")
            {
                zt = 0;
            }
            if (comboBox4.Text == "连载")
            {
                zt = 1;
            }
            if (comboBox4.Text == "完结")
            {
                zt = 2;
            }
            if (comboBox4.Text == "暂停")
            {
                zt = 3;
            }
            string name = comboBox9.Text;
            string fj = "存在";
            string id = comboBox11.Text;
            string jj = textBox8.Text;
            string sql = string.Format("update books set bookname='{0}',bookzhuangtai='{1}',bookjianjie='{2}',fengjin='{3}',bookFenlei='{4}' where bookid='{5}'",name,zt,jj,fj,fl,id);
            try
            {
            if (DBHelper.ExecuteNonQuery(sql))
            {
                MessageBox.Show("修改成功");
                //为下拉框绑定书编号，书本数量
                SqlConnection con5 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                SqlDataAdapter da5 = new SqlDataAdapter("select bookid from books", con5);
                DataSet ds5 = new DataSet();
                da5.Fill(ds5, "bookid");
                DataTable dtGroup5 = ds5.Tables["bookid"];
                comboBox11.DataSource = dtGroup5;
                comboBox11.DisplayMember = "bookid";
                comboBox11.ValueMember = "bookid";
            }
            else
            {
                MessageBox.Show("请联系管理员");
                }
            }
            catch
            {
                MessageBox.Show("哎，终究还是错过了修改");

            }
            comboBox3.Text = k; comboBox4.Text = k; textBox8.Text = k;
            textBox7.Text = k;  textBox3.Text = k;
            }
            catch
            {


            }
        }

        private void dgv6_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
            panel11.BringToFront();
            label32.Show(); label33.Show();  
            comboBox7.Show(); comboBox8.Show(); label38.Show(); label39.Show();
            label37.Show();
            int id = int.Parse(dgv.SelectedRows[0].Cells["c_bookid"].Value.ToString());
            panel11.BringToFront();
            label35.Show(); dgv3.Hide();
            
            //获取书名
            string sql = string.Format("select bookname from Books where bookid='{0}'", id);
            DataTable dt = DBHelper.GetDataTable(sql);
            label35.Text = dt.Rows[0][0].ToString();
            comboBox8.Text = label35.Text;
            //点击dgv里书籍，获取章节内容
            string sql1 = string.Format("select b.zhangjieNeirong from Books a join Zhangjie b on a.bookid = b.bookID where a.bookId = '{0}'", id);
            DataTable dt1 = DBHelper.GetDataTable(sql1);
            richTextBox1.Text = dt1.Rows[0][0].ToString();

            //重新绑定章节（第几章）
            string name1 = dgv.SelectedRows[0].Cells["c_bookName"].Value.ToString();
            string name = comboBox8.Text;
            SqlConnection con3 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da3 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name), con3);
            DataSet ds3 = new DataSet();
            da3.Fill(ds3, "zhangjie");
            DataTable dtGroup1 = ds3.Tables["zhangjie"];
            comboBox7.DataSource = dtGroup1;
            comboBox7.DisplayMember = "zhangjie";
            comboBox7.ValueMember = "zhangjie";
            label90.Text = "0";
            }
            catch
            {


            }
        }

        private void button167_Paint(object sender, PaintEventArgs e)
        {
            System.Drawing.Drawing2D.GraphicsPath buttonPath =
              new System.Drawing.Drawing2D.GraphicsPath();
            // Set a new rectangle to the same size as the button's  
            // ClientRectangle property.
            // 减小矩形的大小。
            // Draw the button's border.
            // Create a circle within the new rectangle.
            //设置按钮的Region.
          
        }

        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
            panel11.BringToFront();
            label32.Show(); label33.Show();  
            label35.Hide(); comboBox7.Show(); comboBox8.Show(); label38.Show(); label39.Show();
            label37.Show();

            int id = 5;
            panel11.BringToFront();
            panel11.BringToFront();
            comboBox8.Hide(); label38.Hide(); label39.Hide(); label35.Show(); dgv3.Hide();
            //获取书名
            label35.Text = "《翻身吧少年》";
            comboBox8.Text = "《翻身吧少年》";
            //点击dgv里书籍，获取章节内容
            string sql1 = string.Format("select zhangjieneirong from zhangjie where bookid='{0}'", id);
            DataTable dt1 = DBHelper.GetDataTable(sql1);
            richTextBox1.Text = dt1.Rows[0][0].ToString();
            //获取选中书的章节，赋给第二个下拉框
            string name3 = comboBox8.Text;
            SqlConnection con33 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da33 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name3), con33);
            DataSet ds33 = new DataSet();
            da33.Fill(ds33, "zhangjie");
            DataTable dtGroup13 = ds33.Tables["zhangjie"];
            comboBox7.DataSource = dtGroup13;
            comboBox7.DisplayMember = "zhangjie";
            comboBox7.ValueMember = "zhangjie";
            }
            catch
            {


            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            try
            {
            panel11.BringToFront();
            label32.Show(); label33.Show();  
            label35.Hide(); comboBox7.Show(); comboBox8.Show(); label38.Show(); label39.Show();
            label37.Show();

            int id = 5;
            panel11.BringToFront();
            panel11.BringToFront();
            comboBox8.Hide(); label38.Hide(); label39.Hide(); label35.Show(); dgv3.Hide();
            //获取书名
            label35.Text = "《花开》";
            comboBox8.Text = "《花开》";
            //点击dgv里书籍，获取章节内容
            string sql1 = string.Format("select zhangjieneirong from zhangjie where bookid='{0}'", id);
            DataTable dt1 = DBHelper.GetDataTable(sql1);
            richTextBox1.Text = dt1.Rows[0][0].ToString();
            //获取选中书的章节，赋给第二个下拉框
            string name3 = comboBox8.Text;
            SqlConnection con33 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da33 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name3), con33);
            DataSet ds33 = new DataSet();
            da33.Fill(ds33, "zhangjie");
            DataTable dtGroup13 = ds33.Tables["zhangjie"];
            comboBox7.DataSource = dtGroup13;
            comboBox7.DisplayMember = "zhangjie";
            comboBox7.ValueMember = "zhangjie";
            }
            catch
            {


            }
        }

        private void button7_Click(object sender, EventArgs e)
        {
            try
            {
            panel11.BringToFront();
            label32.Show(); label33.Show();  
            label35.Hide(); comboBox7.Show(); comboBox8.Show(); label38.Show(); label39.Show();
            label37.Show();

            int id = 5;
            panel11.BringToFront();
            panel11.BringToFront();
            comboBox8.Hide(); label38.Hide(); label39.Hide(); label35.Show(); dgv3.Hide();
            //获取书名
            label35.Text = "《家有刁夫》";
            comboBox8.Text = "《家有刁夫》";
            //点击dgv里书籍，获取章节内容
            string sql1 = string.Format("select zhangjieneirong from zhangjie where bookid='{0}'", id);
            DataTable dt1 = DBHelper.GetDataTable(sql1);
            richTextBox1.Text = dt1.Rows[0][0].ToString();
            //获取选中书的章节，赋给第二个下拉框
            string name3 = comboBox8.Text;
            SqlConnection con33 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da33 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name3), con33);
            DataSet ds33 = new DataSet();
            da33.Fill(ds33, "zhangjie");
            DataTable dtGroup13 = ds33.Tables["zhangjie"];
            comboBox7.DataSource = dtGroup13;
            comboBox7.DisplayMember = "zhangjie";
            comboBox7.ValueMember = "zhangjie";
            }
            catch
            {


            }
        }

        private void button8_Click(object sender, EventArgs e)
        {
            try
            {
            panel11.BringToFront();
            label32.Show(); label33.Show();  
            label35.Hide(); comboBox7.Show(); comboBox8.Show(); label38.Show(); label39.Show();
            label37.Show();

            int id = 5;
            panel11.BringToFront();
            panel11.BringToFront();
            comboBox8.Hide(); label38.Hide(); label39.Hide(); label35.Show(); dgv3.Hide();
            //获取书名
            label35.Text = "《蒹葭》";
            comboBox8.Text = "《蒹葭》";
            //点击dgv里书籍，获取章节内容
            string sql1 = string.Format("select zhangjieneirong from zhangjie where bookid='{0}'", id);
            DataTable dt1 = DBHelper.GetDataTable(sql1);
            richTextBox1.Text = dt1.Rows[0][0].ToString();
            //获取选中书的章节，赋给第二个下拉框
            string name3 = comboBox8.Text;
            SqlConnection con33 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da33 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name3), con33);
            DataSet ds33 = new DataSet();
            da33.Fill(ds33, "zhangjie");
            DataTable dtGroup13 = ds33.Tables["zhangjie"];
            comboBox7.DataSource = dtGroup13;
            comboBox7.DisplayMember = "zhangjie";
            comboBox7.ValueMember = "zhangjie";
            }
            catch
            {


            }
        }

        private void button9_Click(object sender, EventArgs e)
        {
            try
            {
            panel11.BringToFront();
            label32.Show(); label33.Show();  
            label35.Hide(); comboBox7.Show(); comboBox8.Show(); label38.Show(); label39.Show();
            label37.Show();

            int id = 5;
            panel11.BringToFront();
            panel11.BringToFront();
            comboBox8.Hide(); label38.Hide(); label39.Hide(); label35.Show(); dgv3.Hide();
            //获取书名
            label35.Text = "《剑仙无边》";
            comboBox8.Text = "《剑仙无边》";
            //点击dgv里书籍，获取章节内容
            string sql1 = string.Format("select zhangjieneirong from zhangjie where bookid='{0}'", id);
            DataTable dt1 = DBHelper.GetDataTable(sql1);
            richTextBox1.Text = dt1.Rows[0][0].ToString();
            //获取选中书的章节，赋给第二个下拉框
            string name3 = comboBox8.Text;
            SqlConnection con33 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da33 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name3), con33);
            DataSet ds33 = new DataSet();
            da33.Fill(ds33, "zhangjie");
            DataTable dtGroup13 = ds33.Tables["zhangjie"];
            comboBox7.DataSource = dtGroup13;
            comboBox7.DisplayMember = "zhangjie";
            comboBox7.ValueMember = "zhangjie";
            }
            catch
            {


            }
        }

        private void button36_Click(object sender, EventArgs e)
        {
            MessageBox.Show("敬请期待！！！");
        }

        private void button100_Click(object sender, EventArgs e)
        {
            MessageBox.Show("敬请期待！！！");
        }

        private void button116_Click(object sender, EventArgs e)
        {
            MessageBox.Show("敬请期待！！！");
        }

        private void button51_Click(object sender, EventArgs e)
        {
            try
            {
            
            //将这本书的阅读量显示

            panel11.BringToFront();

            label32.Show(); label33.Show();  
            label35.Hide(); comboBox7.Show(); comboBox8.Show(); label38.Show(); label39.Show();
            label37.Show();

            int id = 5;
            panel11.BringToFront();
            panel11.BringToFront();
            comboBox8.Hide(); label38.Hide(); label39.Hide(); label35.Show(); dgv3.Hide();
            //获取书名
            label35.Text = "《路遥的小说世界》";
            comboBox8.Text = "《路遥的小说世界》";
            //点击dgv里书籍，获取章节内容
            string sql1 = string.Format("select zhangjieneirong from zhangjie where bookid='{0}'", id);
            DataTable dt1 = DBHelper.GetDataTable(sql1);
            richTextBox1.Text = dt1.Rows[0][0].ToString();
            //获取选中书的章节，赋给第二个下拉框
            string name3 = comboBox8.Text;
            SqlConnection con33 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da33 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name3), con33);
            DataSet ds33 = new DataSet();
            da33.Fill(ds33, "zhangjie");
            DataTable dtGroup13 = ds33.Tables["zhangjie"];
            comboBox7.DataSource = dtGroup13;
            comboBox7.DisplayMember = "zhangjie";
            comboBox7.ValueMember = "zhangjie";
            }
            catch
            {


            }
        }

        private void button50_Click(object sender, EventArgs e)
        {
            try
            {
            
            panel11.BringToFront();
            label32.Show(); label33.Show();  
            label35.Hide(); comboBox7.Show(); comboBox8.Show(); label38.Show(); label39.Show();
            label37.Show();

            int id = 5;
            panel11.BringToFront();
            panel11.BringToFront();
            comboBox8.Hide(); label38.Hide(); label39.Hide(); label35.Show(); dgv3.Hide();
            //获取书名
            label35.Text = "《沐风》";
            comboBox8.Text = "《沐风》";
            //点击dgv里书籍，获取章节内容
            string sql1 = string.Format("select zhangjieneirong from zhangjie where bookid='{0}'", id);
            DataTable dt1 = DBHelper.GetDataTable(sql1);
            richTextBox1.Text = dt1.Rows[0][0].ToString();
            //获取选中书的章节，赋给第二个下拉框
            string name3 = comboBox8.Text;
            SqlConnection con33 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da33 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name3), con33);
            DataSet ds33 = new DataSet();
            da33.Fill(ds33, "zhangjie");
            DataTable dtGroup13 = ds33.Tables["zhangjie"];
            comboBox7.DataSource = dtGroup13;
            comboBox7.DisplayMember = "zhangjie";
            comboBox7.ValueMember = "zhangjie";
            }
            catch
            {


            }
        }

        private void button49_Click(object sender, EventArgs e)
        {
            try
            {
          
            panel11.BringToFront();
            label32.Show(); label33.Show();  
            label35.Hide(); comboBox7.Show(); comboBox8.Show(); label38.Show(); label39.Show();
            label37.Show();

            int id = 5;
            panel11.BringToFront();
            panel11.BringToFront();
            comboBox8.Hide(); label38.Hide(); label39.Hide(); label35.Show(); dgv3.Hide();
            //获取书名
            label35.Text = "《平凡的世界》";
            comboBox8.Text = "《平凡的世界》";
            //点击dgv里书籍，获取章节内容
            string sql1 = string.Format("select zhangjieneirong from zhangjie where bookid='{0}'", id);
            DataTable dt1 = DBHelper.GetDataTable(sql1);
            richTextBox1.Text = dt1.Rows[0][0].ToString();
            //获取选中书的章节，赋给第二个下拉框
            string name3 = comboBox8.Text;
            SqlConnection con33 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da33 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name3), con33);
            DataSet ds33 = new DataSet();
            da33.Fill(ds33, "zhangjie");
            DataTable dtGroup13 = ds33.Tables["zhangjie"];
            comboBox7.DataSource = dtGroup13;
            comboBox7.DisplayMember = "zhangjie";
            comboBox7.ValueMember = "zhangjie";
            }
            catch
            {


            }
        }

        private void button48_Click(object sender, EventArgs e)
        {
            try
            {
         
            panel11.BringToFront();
            label32.Show(); label33.Show();  
            label35.Hide(); comboBox7.Show(); comboBox8.Show(); label38.Show(); label39.Show();
            label37.Show();

            int id = 5;
            panel11.BringToFront();
            panel11.BringToFront();
            comboBox8.Hide(); label38.Hide(); label39.Hide(); label35.Show(); dgv3.Hide();
            //获取书名
            label35.Text = "《倾世繁华》";
            comboBox8.Text = "《倾世繁华》";
            //点击dgv里书籍，获取章节内容
            string sql1 = string.Format("select zhangjieneirong from zhangjie where bookid='{0}'", id);
            DataTable dt1 = DBHelper.GetDataTable(sql1);
            richTextBox1.Text = dt1.Rows[0][0].ToString();
            //获取选中书的章节，赋给第二个下拉框
            string name3 = comboBox8.Text;
            SqlConnection con33 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da33 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name3), con33);
            DataSet ds33 = new DataSet();
            da33.Fill(ds33, "zhangjie");
            DataTable dtGroup13 = ds33.Tables["zhangjie"];
            comboBox7.DataSource = dtGroup13;
            comboBox7.DisplayMember = "zhangjie";
            comboBox7.ValueMember = "zhangjie";
            }
            catch
            {


            }
        }

        private void button47_Click(object sender, EventArgs e)
        {
            try
            {
    
            panel11.BringToFront();
            label32.Show(); label33.Show();  
            label35.Hide(); comboBox7.Show(); comboBox8.Show(); label38.Show(); label39.Show();
            label37.Show();

            int id = 5;
            panel11.BringToFront();
            panel11.BringToFront();
            comboBox8.Hide(); label38.Hide(); label39.Hide(); label35.Show(); dgv3.Hide();
            //获取书名
            label35.Text = "《人生》";
            comboBox8.Text = "《人生》";
            //点击dgv里书籍，获取章节内容
            string sql1 = string.Format("select zhangjieneirong from zhangjie where bookid='{0}'", id);
            DataTable dt1 = DBHelper.GetDataTable(sql1);
            richTextBox1.Text = dt1.Rows[0][0].ToString();
            //获取选中书的章节，赋给第二个下拉框
            string name3 = comboBox8.Text;
            SqlConnection con33 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da33 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name3), con33);
            DataSet ds33 = new DataSet();
            da33.Fill(ds33, "zhangjie");
            DataTable dtGroup13 = ds33.Tables["zhangjie"];
            comboBox7.DataSource = dtGroup13;
            comboBox7.DisplayMember = "zhangjie";
            comboBox7.ValueMember = "zhangjie";
            }
            catch
            {


            }
        }

        private void button46_Click(object sender, EventArgs e)
        {
            try
            {
     
            panel11.BringToFront();
            label32.Show(); label33.Show();  
            label35.Hide(); comboBox7.Show(); comboBox8.Show(); label38.Show(); label39.Show();
            label37.Show();

            int id = 5;
            panel11.BringToFront();
            panel11.BringToFront();
            comboBox8.Hide(); label38.Hide(); label39.Hide(); label35.Show(); dgv3.Hide();
            //获取书名
            label35.Text = "《山村小医仙》";
            comboBox8.Text = "《山村小医仙》";
            //点击dgv里书籍，获取章节内容
            string sql1 = string.Format("select zhangjieneirong from zhangjie where bookid='{0}'", id);
            DataTable dt1 = DBHelper.GetDataTable(sql1);
            richTextBox1.Text = dt1.Rows[0][0].ToString();
            //获取选中书的章节，赋给第二个下拉框
            string name3 = comboBox8.Text;
            SqlConnection con33 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da33 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name3), con33);
            DataSet ds33 = new DataSet();
            da33.Fill(ds33, "zhangjie");
            DataTable dtGroup13 = ds33.Tables["zhangjie"];
            comboBox7.DataSource = dtGroup13;
            comboBox7.DisplayMember = "zhangjie";
            comboBox7.ValueMember = "zhangjie";
            }
            catch
            {


            }
        }

        private void button68_Click(object sender, EventArgs e)
        {
            MessageBox.Show("敬请期待！！！");
        }

        private void button20_Click(object sender, EventArgs e)
        {
            MessageBox.Show("敬请期待！！！");
        }

        private void button132_Click(object sender, EventArgs e)
        {
            MessageBox.Show("敬请期待！！！");
        }

        private void button52_Click(object sender, EventArgs e)
        {
            MessageBox.Show("敬请期待！！！");
        }

        private void button84_Click(object sender, EventArgs e)
        {
            MessageBox.Show("敬请期待！！！");
        }

        private void dgv_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
            dgv.AutoGenerateColumns = false;
        }

        private void dgv6_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void label40_Click(object sender, EventArgs e)
        {

        }

        private void comboBox13_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void button19_Click(object sender, EventArgs e)
        {
            MessageBox.Show("敬请期待！！！");
        }

        private void button163_Paint(object sender, PaintEventArgs e)
        {
            System.Drawing.Drawing2D.GraphicsPath buttonPath =
             new System.Drawing.Drawing2D.GraphicsPath();
            // Set a new rectangle to the same size as the button's  
            // ClientRectangle property.
            // 减小矩形的大小。
            // Draw the button's border.
            // Create a circle within the new rectangle.
            //设置按钮的Region.
        }

        private void button35_Click(object sender, EventArgs e)
        {
            try
            {
            int id = 11;
            panel11.BringToFront();
            panel11.BringToFront();
            comboBox8.Hide(); label38.Hide(); label39.Hide(); label35.Show(); dgv3.Hide();
            //获取书名
            label35.Text = "剑缘情仇";
            comboBox8.Text = "剑缘情仇";
            //点击dgv里书籍，获取章节内容
            string sql1 = string.Format("select zhangjieneirong from zhangjie where bookid='{0}'", id);
            DataTable dt1 = DBHelper.GetDataTable(sql1);
            richTextBox1.Text = dt1.Rows[0][0].ToString();
            }
            catch
            {


            }
        }

      
        private void LoadData()
        {
            try
            {
            int nStartPos = 0;   //当前页面开始记录行
            int nEndPos = 0;     //当前页面结束记录行
            DataTable dtTemp = dtInfo.Clone();   //克隆DataTable结构框架

            if (pageCurrent == pageCount)
            {
                nEndPos = nMax;
            }
            else
            {
                nEndPos = pageSize * pageCurrent;
            }

            nStartPos = nCurrent;
            zongyeshu.Text = pageCount.ToString();
            dangqian.Text = Convert.ToString(pageCurrent);
            toolStripLabel3.Text = pageCount.ToString();
            toolStripTextBox1.Text = Convert.ToString(pageCurrent);


            //从元数据源复制记录行
            for (int i = nStartPos; i < nEndPos; i++)
            {
                dtTemp.ImportRow(dtInfo.Rows[i]);
                nCurrent++;
            }
            bdsInfo.DataSource = dtTemp;
            bdnInfo.BindingSource = bdsInfo;
            dgv.DataSource = bdsInfo;
            }
            catch
            {


            }

        }
        //菜单相应
        private void bdnInfo_ItemClicked_1(object sender, ToolStripItemClickedEventArgs e)
        {
            try
            {

           
            if (e.ClickedItem.Text == "关闭")
            {
                this.Close();
            }
            if (e.ClickedItem.Text == "上一页")
            {
                pageCurrent--;
                if (pageCurrent <= 0)
                {
                    MessageBox.Show("已经是第一页，请点击“下一页”查看！");
                    return;
                }
                else
                {
                    nCurrent = pageSize * (pageCurrent - 1);
                }
                LoadData();
            }
            if (e.ClickedItem.Text == "下一页")
            {
                pageCurrent++;
                if (pageCurrent > pageCount)
                {
                    MessageBox.Show("已经是最后一页，请点击“上一页”查看！");
                    return;
                }
                else
                {
                    nCurrent = pageSize * (pageCurrent - 1);
                }
                LoadData();
                }
            }
            catch
            {


            }
        }

        private void bdnInfo_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            try
            {
            if (e.ClickedItem.Text == "关闭")
            {
                this.Close();
            }
            if (e.ClickedItem.Text == "上一页")
            {
                pageCurrent--;
                if (pageCurrent <= 0)
                {
                    MessageBox.Show("已经是第一页，请点击“下一页”查看！");
                    return;
                }
                else
                {
                    nCurrent = pageSize * (pageCurrent - 1);
                }
                LoadData();
            }
            if (e.ClickedItem.Text == "下一页")
            {
                pageCurrent++;
                if (pageCurrent > pageCount)
                {
                    MessageBox.Show("已经是最后一页，请点击“上一页”查看！");
                    return;
                }
                else
                {
                    nCurrent = pageSize * (pageCurrent - 1);
                }
                LoadData();
                }
            }
            catch
            {


            }
        }

        private void toolStripLabel5_Click(object sender, EventArgs e)
        {
            dgv.BringToFront(); dgv6.Hide();
        }

        private void 删除章节VToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
            //温馨提示
            if (MessageBox.Show("确定删除?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                string zj = comboBox7.Text;
                //获取章节id用于删除章节
                string id = dgv3.SelectedRows[0].Cells["dataGridViewTextBoxColumn1"].Value.ToString();
                string sql1 = string.Format("delete from zhangjie where zhangjie='{0}' and bookid='{1}'", zj, id);
                if (DBHelper.ExecuteNonQuery(sql1))
                {
                    MessageBox.Show("删除成功");
                    //获取选中书的章节。重新绑定数据
                    string name = comboBox8.Text;
                    SqlConnection con3 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                    SqlDataAdapter da3 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name), con3);
                    DataSet ds3 = new DataSet();
                    da3.Fill(ds3, "zhangjie");
                    DataTable dtGroup1 = ds3.Tables["zhangjie"];
                    comboBox7.DataSource = dtGroup1;
                    comboBox7.DisplayMember = "zhangjie";
                    comboBox7.ValueMember = "zhangjie";
                    //给combobox6绑定章节
                    string name2 = comboBox8.Text;
                    SqlConnection con2 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
                    SqlDataAdapter da2 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name2), con2);
                    DataSet ds2 = new DataSet();
                    da3.Fill(ds2, "zhangjie");
                    DataTable dtGroup2 = ds2.Tables["zhangjie"];
                    comboBox6.DataSource = dtGroup1;
                    comboBox6.DisplayMember = "zhangjie";
                    comboBox6.ValueMember = "zhangjie";
                    //刷新查看章节的dgv
                    string sql3 = string.Format("select a.bookname, b.zhangjie, b.zhangjiename from books a join zhangjie b on a.bookid = b.bookid where a.bookname = '{0}'", name);
                    DataTable dt3 = DBHelper.GetDataTable(sql3);
                    dgv6.DataSource = dt3;
                    //刷新dgv书籍
                    string sql4 = "select * from books";
                    DataTable dt4 = DBHelper.GetDataTable(sql4);
                    dgv.DataSource = dt4;
                }
                else
                {
                    MessageBox.Show("请联系管理员");
                }
            }
            else
            {
                MessageBox.Show("哎，终究还是错过了删除");
                }
            }
            catch
            {


            }
        }

        private void 更改TToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
            if (MessageBox.Show("确定更改?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                string zj = comboBox7.Text;
                string nr = richTextBox1.Text;
                int id = int.Parse(dgv3.SelectedRows[0].Cells[0].Value.ToString());
                string sql = string.Format("update zhangjie set zhangjieneirong='{0}' where bookid='{1}' and zhangjie='{2}'", nr, id, zj);
                if (DBHelper.ExecuteNonQuery(sql))
                {
                    MessageBox.Show("更改成功");
                    //刷新内容
                    string sql1 = string.Format("select b.zhangjieNeirong from Books a join Zhangjie b on a.bookid = b.bookID where a.bookId = '{0}'", id);
                    DataTable dt1 = DBHelper.GetDataTable(sql1);
                    richTextBox1.Text = dt1.Rows[0][0].ToString();
                }
                else
                {
                    MessageBox.Show("更改失败，请联系管理员");
                }
            }
            else
            {
                MessageBox.Show("哎，终究还是错过了更改");
                }
            }
            catch
            {


            }
        }

        private void 查看此章节内容RToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
            panel11.BringToFront();
            label32.Show(); label33.Show();  
            label35.Hide(); comboBox7.Show(); comboBox8.Show(); label38.Show(); label39.Show();
            label37.Show();
            int id = int.Parse(dgv.SelectedRows[0].Cells[0].Value.ToString());
            panel11.BringToFront();
            comboBox8.Hide(); label38.Hide(); label39.Hide(); label35.Show(); dgv3.Hide();
            comboBox8.Text = label35.Text;

            //获取书名
            string sql = string.Format("select bookname from Books where bookid='{0}'", id);
            DataTable dt = DBHelper.GetDataTable(sql);
            label35.Text = dt.Rows[0][0].ToString();
            //点击dgv里书籍，获取章节内容
            string sql1 = string.Format("select b.zhangjieNeirong from Books a join Zhangjie b on a.bookid = b.bookID where a.bookId = '{0}'", id);
            DataTable dt1 = DBHelper.GetDataTable(sql1);
            richTextBox1.Text = dt1.Rows[0][0].ToString();

            //重新绑定章节（第几章）
            string name1 = dgv.SelectedRows[0].Cells[2].Value.ToString();
            comboBox8.Text = name1; string name = comboBox8.Text;
            SqlConnection con3 = new SqlConnection("server=.;database=BooksDB;Integrated Security=True;");
            SqlDataAdapter da3 = new SqlDataAdapter(string.Format("select b.zhangjie from books a join zhangjie b on a.bookid=b.bookid where a.bookname='{0}'", name), con3);
            DataSet ds3 = new DataSet();
            da3.Fill(ds3, "zhangjie"); 
            DataTable dtGroup1 = ds3.Tables["zhangjie"];
            comboBox7.DataSource = dtGroup1;
            comboBox7.DisplayMember = "zhangjie";
            comboBox7.ValueMember = "zhangjie";
            }
            catch
            {


            }
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            //界面隐藏
            this.WindowState = FormWindowState.Minimized;
        }
    }
}

